package com.eeepay.eeepay_v2.model;

/**
 * Created by zw on 2016/3/3 0003.
 * 自定义时间类
 */
public class CustomTime {

    private int year;
    private int month;
    private int day;
    private int hour;

    public int getYear() {
        return year;
    }

    public void setYear(int year) {
        this.year = year;
    }

    public int getMonth() {
        return month;
    }

    public void setMonth(int month) {
        this.month = month;
    }

    public int getDay() {
        return day;
    }

    public void setDay(int day) {
        this.day = day;
    }

    public int getHour() {
        return hour;
    }

    public void setHour(int hour) {
        this.hour = hour;
    }

    public int getMinute() {
        return minute;
    }

    public void setMinute(int minute) {
        this.minute = minute;
    }

    private int minute;

    @Override
    public String toString() {
        return year + "-" + month  + "-"
                + day + " "+ hour + ":" + minute;
    }


    /**
     * *********************华丽的分割线***************************
     */

    /**
     * 从字符串中提取时间
     *         xxxx年xx月xx日xx:xx
     * @param time
     * @return
     */
    public static CustomTime getTime(String time){
        CustomTime cTime = new CustomTime();
        String[] s = time.split("年");
//        cTime.setYear(s[0]);
//        s = s[1].split("月");
//        cTime.setMonth(s[0]);
//        s = s[1].split("日");
//        cTime.setDay(s[0]);
//        s = s[1].split(":");
//        cTime.setHour(s[0]);
//        cTime.setMinute(s[1]);

        return cTime;
    }

    /**
     * 获取时间的字符串格式   2015-10-9 12:03
     * @return
     */
    public String time2String(){
        return this.toString();
    }

    /**
     * 日期字符串
     * @return
     */
    public String date2String(){
        return year + "-" + month  + "-" + day;
    }
}
